<tagLib name="strends" />
<include file="Public:header" />
<script type="text/javascript" src="__TMPL__Static/Js/dataList.js"></script>
<div class="handle-btns">
	<strends:linkBtn text="{%RETURN_CATEGORY_LIST}" href="{:U('GoodsCategory/index')}" />
	<strends:linkBtn text="{%GOODSCATEGORYTAGS_SETTING}" href="{:U(MODULE_NAME.'/setting')}" />
	<strends:imageBtn id="removeData" name="removeData" value="{%REMOVE}" click="removeData(this,'checkList')" />
	<form action="__APP__">
		<span>{%TAG_TYPE}</span>
		<select name="tagtype">
			<option value="" <if condition="$tagtype eq -1">selected="selected"</if>>{%TAGALL}</option>
			<option value="0" <if condition="$tagtype eq 0">selected="selected"</if>>{%NORMAL}</option>
			<option value="1" <if condition="$tagtype eq 1">selected="selected"</if>>{%STYLE}</option>
			<option value="2" <if condition="$tagtype eq 2">selected="selected"</if>>{%ITEM}</option>
			<option value="3" <if condition="$tagtype eq 3">selected="selected"</if>>{%SPEC}</option>
			<option value="4" <if condition="$tagtype eq 4">selected="selected"</if>>{%BRAND}</option>
			<option value="5" <if condition="$tagtype eq 5">selected="selected"</if>>{%MATERIAL}</option>
			<option value="6" <if condition="$tagtype eq 6">selected="selected"</if>>{%GOODS}</option>			
		</select>
		<small></small>
		<span>{%TAG_NAME}</span>
		<input class="textinput" type="text" value="{$tag_name}" name="tag_name" size="20" />
		<small></small>
		<input class="submit_btn" type="submit" value="{%SEARCH}" />
		<input type="hidden" name="{:c('VAR_MODULE')}" value="{$module_name}" />
		<input type="hidden" name="{:c('VAR_ACTION')}" value="index" />
	</form>
</div>
<strends:list id="checkList" pk="tag_id" style="list" name="tags" checkbox="true" action="true" datasource="list" 
show="tag_name:{%TAG_NAME}|~left,type|getTagType:{%TAG_TYPE}|100,is_index|getStatusImg:{%IS_INDEX}|90:toggleYesNo|cate_id^tag_id,is_hot|getStatusImg:{%IS_HOT}|90:toggleYesNo|cate_id^tag_id,weight:{%WEIGHT}|80:numberEdit|tag_id" 
actionlist="removeData:{%REMOVE}:tag_id" action_width="80"/>
<div class="pager">{$page}</div>
<include file="Public:footer" />

<script>
function toggleYesNo(obj,cate_id,tag_id,name)
{
	if($('img',obj).length == 0)
		return false;
	
	var module = obj.getAttribute('module');
	var query = new Object();
	query.field = name;
	query.val = $('img',obj).get(0).getAttribute('status');
	query.cate_id = cate_id;
	query.tag_id = tag_id;
	
	$.ajax({
		url: APP + '?' + VAR_MODULE + '=' + module + '&' + VAR_ACTION + '=toggleYesNo',
		type:"POST",
		cache: false,
		data:query,
		dataType:"json",
		success: function(result){
			if(result.isErr == 0)
			{
				var img = $('img',obj).get(0);
				var src = img.src.replace(query.val + '.gif',result.content + '.gif');
				img.setAttribute('status',result.content);
				img.src = src;
			}
			else
				$.ajaxError();
		}
	});
}
</script>